#include "code_generator.h"

namespace pp
{
    FieldInfo::FieldInfo(const std::string& name, const std::string& tag, const std::string& ftype,
        const std::string& subtype, const std::string& value, const std::string& def, const std::string& desc,
        const std::string& size, const std::string& jsonName, const std::string& jsonOmitEmpty)
        : m_sName(name), m_sTag(tag), m_sType(ftype), m_sSubType(subtype),
        m_sValue(value), m_sDefault(def), m_sDesc(desc), m_sSize(size), m_sJsonName(jsonName),
        m_sJsonOmitEmpty(jsonOmitEmpty)
    {
    }

    StructInfo::StructInfo(const std::string& name, const std::string& stype, const std::string& desc) :
        m_sName(name), m_sType(stype), m_sDesc(desc)
    {
    }

    void CodeGenerator::Reset(const std::string& srcfile)
    {
        m_sSrcFile = srcfile;
        m_oImports.clear();
        m_sPackage = "";
        m_oConsts.clear();
        m_oEnums.clear();
        m_oStructs.clear();
    }

    void CodeGenerator::HandleImport(const std::string& imports)
    {
    }

    void CodeGenerator::HandlePackage(const std::string& package)
    {
        m_sPackage = package;
    }

    void CodeGenerator::HandleOption(const std::string& name, const std::string& value)
    {
    }

    void CodeGenerator::HandleConst(const std::shared_ptr<FieldInfo>& fieldInfo)
    {
        m_oConsts.push_back(fieldInfo);
    }

    // 处理pp文件中的enum定义
    void CodeGenerator::HandleEnum(const std::shared_ptr<StructInfo>& structInfo)
    {
        m_oEnums.push_back(structInfo);
    }

    void CodeGenerator::HandleStruct(const std::shared_ptr<StructInfo>& structInfo)
    {
        m_oStructs.push_back(structInfo);
    }
};
